# Test simMyro

def testRun():
    loc,gz,ee = initSim()
    print simMyro.get_loc()
    print ee
    loc,gz,cc = go(1)
    gLoc = simMyro.get_loc()
    print gLoc
    print cc
    counter = 0
    while gLoc != 52 and counter < 200:
        counter += 1
        if gLoc == 56 or gLoc == 32:
            R90()
            loc,gz,cc = go(1)
        else:
            p = getPixel(gz,120,22)
            rgb = getRGB(p)
            if rgb == (0,0,0):
                loc,gz,cc = go(1)
            else:
                gz = R90()
                p = getPixel(gz,120,22)
                rgb = getRGB(p)
                if rgb == (0,0,0):
                    loc,gz,cc = go(1)
                else:
                    L90()
                    gz = L90()
                    p = getPixel(gz,120,22)
                    rgb = getRGB(p)
                    if rgb == (0,0,0):
                        loc,gz,cc = go(01)
                    else:
                        gz = L90()
                        p = getPixel(gz,120,22)
                        rgb = getRGB(p)
                        if rgb == (0,0,0):
                            loc,gz,cc = go(1)
                        else:
                            print "Problem at"
                            print simMyro.get_loc()
                            stp()
        gLoc = simMyro.get_loc()
        printSomMyro()
        print cc
    return 'done'

def isNewDir(gm):
    return gm[0] or gm[1] or gm[3]

def goFirstDir(gm):
    print 'goFirstDir'
    if gm[0]:
        return go(1)
    elif gm[1]:
        R90()
        return go(1)
    elif gm[2]:
        R90()
        R90()
        return go(1)
    elif gm[3]:
        R90()
        R90()
        R90()
        return go(1)
    else:
        print 'ERROR - bad map'
        return 'error'

def goFirstNewDir(gm):
    print 'goFirstNewDir'
    if gm[0]:
        return go(1)
    elif gm[1]:
        R90()
        return go(1)
    elif gm[3]:
        R90()
        R90()
        R90()
        return go(1)
    else:
        print 'ERROR - no New Direction'
        return 'error'

def canGo(roadAhead):
    if isWall(roadAhead):
        return False
    else:
        return True

def canGoMap(gz):
    gmap = [not isWall(gz)]
    for i in range(3):
        road = R90()
        gmap.append(not isWall(road))
    R90()
    return gmap

def goIfCan(roadAhead,see):
    show(roadAhead)
    pause(2)
    if isWall(roadAhead):
        print 'ROTATE'
        gaze = R90()
    else:
        print 'GO 1'
        see,gaze = go(1)
    return see,gaze
